package com.mbigger.thriftserver;

import com.mbigger.generate.Hello.Processor;
import org.apache.thrift.TProcessor;
import org.apache.thrift.protocol.TBinaryProtocol.Factory;
import org.apache.thrift.server.TServer;
import org.apache.thrift.server.TSimpleServer;
import org.apache.thrift.server.TServer.Args;
import org.apache.thrift.transport.TServerSocket;
import org.apache.thrift.transport.TTransportException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class ThriftServerApplication {
    private static final Logger log = LoggerFactory.getLogger(ThriftServerApplication.class);

    public ThriftServerApplication() {
    }

    public static void main(String[] args) {
        SpringApplication.run(ThriftServerApplication.class, args);

        try {
            log.info("服务端开启....");
            TProcessor tprocessor = new Processor(new HelloServiceImpl());
            TServerSocket serverTransport = new TServerSocket(9898);
            Args tArgs = new Args(serverTransport);
            tArgs.processor(tprocessor);
            tArgs.protocolFactory(new Factory());
            TServer server = new TSimpleServer(tArgs);
            server.serve();
        } catch (TTransportException var5) {
            log.error(var5.getMessage());
        }

    }
}
